package com.ruoyi.test.dataSource;

import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;

/**
 * @author: 吴文兵
 * @date: 2025-06-04 14:27
 */
public class ChangeDataSource {
    public static void main(String[] args) {
        // 手动切换数据源
        DynamicDataSourceContextHolder.push("slave");

        //业务逻辑
        //...

        //切回主数据源
        DynamicDataSourceContextHolder.clear();
    }
}